package org.chen.model.elastic;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.chen.model.vo.ImageInfoVO;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.text.DateFormat;
import java.util.Date;
import java.util.List;

// Elasticsearch存储实现
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Document(indexName = "articles")
@JsonIgnoreProperties(ignoreUnknown = true)
public class ArticleIndex {
    @Id
    private String id;

    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String title;

    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String summary;

    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String author;

    @Field(type = FieldType.Text, analyzer = "ik_smart")
    private String category;

    @Field(type = FieldType.Keyword)
    private String thumbnailUrl;

    @Field(type = FieldType.Text, analyzer = "ik_smart")
    private List<String> tags;

    @Field(type = FieldType.Keyword)
    private String source;

    @Field(type = FieldType.Integer)
    private Integer status;

    @Field(type = FieldType.Boolean)
    private Boolean isTop;

    @Field(type = FieldType.Long)
    private Long viewCount;

    @Field(type = FieldType.Date,format = {},pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    @Field(type = FieldType.Integer)
    private Integer topOrder;

    @Field(type = FieldType.Boolean)
    private Boolean isHot;

    @Field(type = FieldType.Integer)
    private Integer hotOrder;

    @Field(type = FieldType.Boolean)
    private Boolean isRecommend;

    @Field(type = FieldType.Integer)
    private Integer recommendOrder;
}
